import re

target_str = '''
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Second Task</title>
</head>
<body>
    <div id="one" style="text-align: center;">
        <td>
            <tr><h2>one</h2></tr>
            <tr><h2>two</h2></tr>
            <tr><h2>three</h2></tr>
        </td>
    </div>
    <div id="two" style="text-align: center;">
        <a href="#1">Link 1</a>
        <a href="#2">Link 2</a>
        <a href="#3">Link 3</a>
    </div>
</body>
</html>
'''

if __name__ == "__main__":
    con = re.findall(r'<meta.*?>', target_str)
    s = ""
    for c in con:
        s += (c+'\n')
    con = re.findall(r'<tr>(.*?)</tr>', target_str)
    for c in con:
        s += (c+'\n')
    print(s)
    cs = re.findall(r'<a\s+href=\"(.*?)\".*?>', target_str)
    consult = target_str
    for c in cs:
        consult = consult.replace(str(c), 'https://cn.bing.com')
    print(consult)